package com.kfm.login.config;

import com.kfm.login.interceptor.AccessCountInterceptor;
import com.kfm.login.interceptor.BlackInterceptor;
import com.kfm.login.interceptor.LoginCountInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginCountInterceptor loginCountInterceptor;
    @Autowired
    private BlackInterceptor blackInterceptor;
    @Autowired
    private AccessCountInterceptor accessCountInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginCountInterceptor).addPathPatterns("/user/login");
        registry.addInterceptor(accessCountInterceptor).addPathPatterns("/*").excludePathPatterns("/error", "/remember", "/static/**");
        // 拦截器拦截所有请求，除了 /error ，/static
        registry.addInterceptor(blackInterceptor).addPathPatterns("/*").excludePathPatterns("/error", "/remember", "/static/**");
    }
}
